package com.IteratorDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @Author milian
 * @Date 2021/7/24 0024 16:59
 */
public class demo1 {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<>();
        collection.add("123");
        collection.add("234");
        collection.add("sasd");
        Iterator iterator = collection.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        for (String s: collection
             ) {
            System.out.println(s);
        }

    }
}
